import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.Semaphore;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @ClassName A9
 * @Description
 * @Author Jingxiao.Ye
 * @Date 2021/11/28 下午11:49
 * @Version V1.0
 * @Since JDK 11
 */
public class A9 {

    public static void main(String[] args) throws BrokenBarrierException, InterruptedException {
        AtomicInteger atomicInteger = new AtomicInteger();

        Semaphore semaphore = new Semaphore(1);
        Thread thread = new Thread(() -> {
            try {
                Integer call = new Task().call();
                atomicInteger.set(call);
                semaphore.release();
            } catch (Exception e) {
                e.printStackTrace();
            }
        });
        thread.start();
        semaphore.acquire(2);
        System.out.println(atomicInteger.get());
    }
}
